import type * as Role from "./type"
import { request } from "@/http/axios"

/** 增改 */
export function save(data: Role.RoleData) {
  return request({
    url: "system/role/save",
    method: "post",
    data
  })
}

/** 删 */
export function del(id: number) {
  return request({
    url: `system/role/delete/${id}`,
    method: "post"
  })
}

/** 查 */
export function queryPage(data: Role.RoleQueryData) {
  return request<Role.RoleResponseData>({
    url: "system/role/page",
    method: "post",
    data
  })
}

/**
 * 检查字段是否重复
 */
export function checkNotRepeat(id: number | null, column: string, value: string) {
  return request<ApiResponseData<boolean>>({
    url: `system/role/check`,
    method: "post",
    data: {
      id,
      column,
      value
    }
  })
}

/**
 * 修改状态
 */
export function updateEnable(id: number, enable: boolean) {
  return request({
    url: `system/role/updateEnable/${id}`,
    method: "post",
    params: {
      enable
    }
  })
}
